<template>
  <div>
    <h2>添加员工</h2>
    姓名<input type="txet" v-model="username">
    密码<input type="txet" v-model="password">
    员工部门分类分类<select v-model="dept_id">
      <option v-for="i in depts" :value="i.id" :key="i.id">{{i.username}}</option>

    </select>
    <button @click="sub">添加</button>
  </div>
</template>

<script>
export default {
  data(){
    return{
      username:'',
      password:'',
      dept_id:0,
      depts:[]
    }
  },
  mounted(){
    this.axios({
        url:'http://127.0.0.1:8000/app01/deptar/',
        method:'get',
      }).then(res=>{
        alert(res.data.msg);
      })
  },
  methods:{
    sub:function(){
      let formdata=new FormData();
      formdata.append('username',this.username);
      formdata.append('password',this.password);
      formdata.append('dept_id',this.dept_id);
      this.axios({
        url:'http://127.0.0.1:8000/app01/staff/',
        method:'post',
        data:formdata
      }).then(res=>{
        alert(res.data.msg);
      })
    }
  }
}
</script>

<style>

</style>

